package com.da.javatest.demo.basic;

import java.util.List;
import java.util.stream.Collectors;

import com.alibaba.fastjson.JSONObject;

import lombok.Data;

/**
 * @author chenlida
 * @date 2019/5/14 14:49
 * @description
 */
public class JsonTest {
    public static void main(String[] args) {
        String json =
            "{\"lz-sg\":{\"name\":\"aaa\",\"env_type\":\"bbb\",\"code\":\"ccc\",\"visible\":\"true\"},"
                + "\"lz-ss\":{\"name\":\"ccc\",\"env_type\":\"bbb\",\"code\":\"aaa\",\"visible\":\"false\"}}";
        JSONObject object = JSONObject.parseObject(json);
        List<OverseaEnvDTO> list = object.keySet().stream().map(
            key -> JSONObject.parseObject(object.get(key).toString(), OverseaEnvDTO.class)).collect(
            Collectors.toList());
        list.forEach(System.out::println);
    }

    @Data
    private static class OverseaEnvDTO {
        private String name;
        private String envType;
        private String code;
        private Boolean visible;
    }
}
